from imports.valuelist import *

class ForbiddenList(ValueList):
    def __init__(self, rows, columns):
        self.row_list = []
        self.column_list = []
        max_value = max(rows,columns)
        for i in range(rows):
            self.row_list.append(list(range(1, max_value + 1)))
        for i in range(columns):
            self.column_list.append(list(range(1, max_value + 1)))
            
    def get_possibility(self, index):
        return set(self.row_list[self.row_of(index)]).intersection(set(self.column_list[self.column_of(index)]))
        
    def is_in_row(self, index, value):
        if value in self.row_list[self.row_of(index)]:
            return False
        return True
    def is_in_column(self, index, value):
        if value in self.column_list[self.column_of(index)]:
            return False
        return True
        
    def is_valid(self, index, value):
        set = self.get_possibility(index)
        if value in set:
            return True
        return False